﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Zyg.Utility.Helper;

namespace Zyg.SSO.Web.User
{
    public partial class Mine : Zyg.SSO.Web.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BindData();
        }

        protected void BindData()
        {
            Zyg.SSO.Core.Business.Account account = (Zyg.SSO.Core.Business.Account)Session["User"];

            if (account == null)
            {
                throw new Exception("对不起，你所访问的页面不存在");
            }

            AccountDateCreated.Text = account.DateCreated.ToString("yyyy年MM月dd日 H点mm分");
            AccountEmail.Text = account.Email;
            AccountName.Text = account.Name;
            AccountRemark.Text = account.Remark;
            AccountRole.Text = account.Role.Name;
            AccountTel.Text = account.Telephone.IsNullOrEmpty() ? "暂未设定" : account.Telephone;

            if (!string.IsNullOrEmpty(account.PictureAddress))
            {
                System.IO.FileInfo fileInfo = new System.IO.FileInfo(Server.MapPath(account.PictureAddress));

                if (fileInfo.Exists)
                {
                    AccountPic.ImageUrl = account.PictureAddress;
                }
                else
                {
                    AccountPic.ImageUrl = "~/Content/Account/no_head.gif";
                }
            }
            else
            {
                AccountPic.ImageUrl = "~/Content/Account/no_head.gif";
            }
        }
    }
}
